﻿/* 
 * yaku
 * http://code.google.com/p/yaku/
 * 
 * Copyright 2011, Bryan McKelvey
 * Licensed under the MIT license
 * http://www.opensource.org/licenses/mit-license.php
 */

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace yaku
{
    /// <summary>
    /// Interaction logic for Kanji.xaml
    /// </summary>
    public partial class KanjiWindow : Window
    {
        private TextBox targetTextBox;

        public KanjiWindow(ref TextBox targetTextBox)
        {
            InitializeComponent();
            this.targetTextBox = targetTextBox;
        }

        public void Search()
        {
            Dictionaries.KanjiDic.Search(KunyomiTextBox.Text, OnyomiTextBox.Text,
                StrokesCountComboBox.SelectedIndex, ref KanjiDataGrid);
        }

        private void SendToTarget(string kanji)
        {
            targetTextBox.Text += kanji;
        }

        private void RadicalButton_Click(object sender, RoutedEventArgs e)
        {
            RadicalsTextBox.Text += ((Button)sender).Content.ToString();
        }

        private void Grid_KeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Enter:
                    Search();
                    break;
                case Key.Escape:
                    Close();
                    break;
            }
        }
    }
}
